/*************************************************************************
	> File Name: P2367.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-10 10:59:32
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 5000000

int arr[MAX_N + 5];
int d[MAX_N + 5];

int main() {
    int n, p;
    cin >> n >> p;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    for (int i = 1; i <= n; i++) {
        d[i] = arr[i] - arr[i - 1];
    }
    while (p--) {
        int x, y, val;
        cin >> x >> y >> val;
        d[x] += val;
        d[y + 1] -= val;
    }
    int ans = 200;
    for (int i = 1; i <= n; i++) {
        arr[i] = arr[i - 1] + d[i];
        ans = min(ans, arr[i]);
    }
    cout << ans << endl;
    return 0;
}
